package com.AJava1710D.设计模式.单例.懒汉式;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * 作者: LCG
 * 日期: 2020/6/29 09:32
 * 描述:
 */
public class TestLanHan {

    public static void main(String[] args) throws ExecutionException, InterruptedException {


     for(int i=0;i<100;i++){
         FutureTask<LanHanShi> futureTask=new FutureTask<>(new Callable<LanHanShi>() {
             @Override
             public LanHanShi call() throws Exception {
                 return LanHanShi.getInstance();
             }
         });
         Thread thread=new Thread(futureTask);


         FutureTask<LanHanShi> futureTask2=new FutureTask<>(new Callable<LanHanShi>() {
             @Override
             public LanHanShi call() throws Exception {
                 return LanHanShi.getInstance();
             }
         });
         Thread thread2=new Thread(futureTask2);


         FutureTask<LanHanShi> futureTask3=new FutureTask<>(new Callable<LanHanShi>() {
             @Override
             public LanHanShi call() throws Exception {
                 return LanHanShi.getInstance();
             }
         });
         Thread thread3=new Thread(futureTask3);


         thread.start();
         thread2.start();
         thread3.start();

         LanHanShi LanHanShi = futureTask.get();

         LanHanShi LanHanShi1 = futureTask2.get();

         LanHanShi LanHanShi2 = futureTask3.get();

         System.out.println(i+"=======>"+(LanHanShi==LanHanShi1));
         System.out.println(i+"=======>"+(LanHanShi==LanHanShi2));
         System.out.println(i+"=======>"+(LanHanShi1==LanHanShi2));

     }

    }

}
